package com.yc.home.cloudother.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.entity.Type;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lzk
 * @since 2024-09-22
 */
public interface TypeMapper extends BaseMapper<Type> {

    @Select("select tname, count from type right join (select tid, sum(sum) as count from doquestion GROUP BY tid ORDER BY count desc limit 0,5) as a on a.tid = type.id ")
    List<Map<String, String>> getfivetype();

    @Insert("insert into type(tname,image,tid,status) value(#{name},#{pic},#{tid},1)")
    int in(@Param("name") String name, @Param("pic") String pic, @Param("tid") String tid);

    @Update("UPDATE type set tid = #{tid}, tname = #{tname}, image = #{pic} where id = #{id}")
    int up(@Param("id") String id, @Param("tname") String tname, @Param("pic") String pic, @Param("tid") String tid);

}
